package cn.edu.demo.controller;

import cn.edu.demo.pojo.Passenger;
import cn.edu.demo.pojo.ResponseResult;
import cn.edu.demo.service.PassengerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
//@Controller
public class EnrollController {

    @Autowired
    PassengerService passengerservice;

    @RequestMapping("/user/register")
    @ResponseBody
    public ResponseResult register(String username,Long phonenum,String password,String repassword,String idcard,String name,Integer sex){
        //todo 虽然也不知道能不能写出来 String username,String password,Long phone,String id,Integer sex,String fullnameP
        if(username!=null&&phonenum!=null&&password!=null&&repassword!=null&&idcard!=null&&name!=null&&sex!=null){
            if (password.equals(repassword)){
                int i = passengerservice.enroll(username, password, phonenum, idcard, sex, name);
                if (i!=0)
                    return new ResponseResult(110,"注册成功",null);
                else
                    return new ResponseResult(113,"注册失败",null);
            }
            else {
                return new ResponseResult(112,"两次密码不相同",null);
            }
        }else
            return new ResponseResult(111,"输入数据有空值",null);
    }
}
